﻿<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>用户消费流水</title>
  <link href="../../Content/timepicker/css/jquery-ui-1.8.17.custom.css" rel="stylesheet" type="text/css" />
     <link type="text/css" href="../../Content/timepicker/css/jquery-ui-timepicker-addon.css" rel="stylesheet" />
    <script type="text/javascript" src="../../Content/timepicker/js/jquery-1.7.1.min.js"></script>
    <script src="../../Content/JS/layer-v1.7.1/layer/layer.js" type="text/javascript"></script>
	<script type="text/javascript" src="../../Content/timepicker/js/jquery-ui-1.8.17.custom.min.js"></script>
	<script type="text/javascript" src="../../Content/timepicker/js/jquery-ui-timepicker-addon.js"></script>
    <script type="text/javascript" src="../../Content/timepicker/js/jquery-ui-timepicker-zh-CN.js"></script>
    <link href="../../Content/Themes/blue2/css.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
        .centerALL{ width:800px; margin:0px auto; }
        
    #showWater{width:750px; border-color:#1C1C1C; overflow:scroll;text-align:center;border-collapse:collapse; border-spacing:0; margin-bottom:10px;  margin-top:5px;}
      #showWater  th,td{ word-break:keep-all; white-space:nowrap;  border:1px black solid ; padding:3px; }
      .leftNew{ width:300px; height:70px; float:left;}
      .right{ width:450px; height:70px; float:left; line-height:50px;}
       .pager{ margin-left:22%;  padding-top:20px;}
    </style>
</head>
<body class="main">

 <div  class="AllWebTopDiv">
    <div class="path">
             <div class="nav">
               <a href="#">用户流水</a>
             </div>
        </div>
       <div class="content">
        <div class="centerALL">
          <div>
           <div class="leftNew"> 
          <label>起始时间：</label>   <input type="text" name="datetime" id="expiresDate" class="ui_timepicker" value="">
          <br /><br />
          <label>结束时间：</label> <input  type="text" id="expiresDate2"  class="ui_timepicker" />
          
         </div>
           <div class="right">
           <label>操作员：</label>
           <%:Html.DropDownList("operator")%>
           <input  type="button" value="查找" class="button2" onclick="SelectByTime()" />
           <input type="button" value="导出" class="button2"  onclick="daochu()"/>
           <input  type="button" value="清除日志" class="button2"  onclick="delWater()"/>
            <input  type="button" id="exit" value="关闭" onclick="closeWindows();" class="button2"/>
           </div>
          </div>
          <div class="showData">
            <table id="showWater">
              <tr class="DGHeaderStyle">
               <th>管理员</th>
               <th>用户编号</th>
               <th>消费日期</th>
               <th>商品编号</th>
               <th>商品单击</th>
               <th>购买数量</th>
             </tr>
            </table>
              <div class="pager">
                           <input  type="button" onmouseover="this.style.fontWeight='bold'" onmouseout="this.style.color='black';this.style.fontWeight='normal'" onclick="newPage('首页')"style="cursor:pointer"  value="首页" class="button"/>
                            <input type="button" value="上一页" onmouseover="this.style.fontWeight='bold'" onmouseout="this.style.color='black';this.style.fontWeight='normal'" onclick="newPage('上一页')"style="cursor:pointer" class="button"/>
                            <input type="button" value="下一页" onmouseover="this.style.fontWeight='bold'" onmouseout="this.style.color='black';this.style.fontWeight='normal'" onclick="newPage('下一页')"style="cursor:pointer" class="button"/>
                            <input type="button" value="末页" onmouseover="this.style.fontWeight='bold'" onmouseout="this.style.color='black';this.style.fontWeight='normal'" onclick="newPage('末页')"style="cursor:pointer" class="button"/>
      
       　                    共 <label id="maxPage">1</label> 页 第 <label id="CurrentPage">1</label> 页
                       </div>
          </div>
        </div>
       </div>
     </div>
</body>
</html>

<script type="text/javascript">

    var pageNum=1;
    var pageSize=5;
    var expiresDate="";
    var expiresDate2=""; 
    var opeator="";
    var select=false;
      $(function () {
        $("#expiresDate").datetimepicker({ 
            showSecond: true,
            timeFormat: 'hh:mm:ss',
            stepHour: 1,
            stepMinute: 1,
            stepSecond: 1
        })
         $("#expiresDate2").datetimepicker({
            showSecond: true,
            timeFormat: 'hh:mm:ss',
            stepHour: 1,
            stepMinute: 1,
            stepSecond: 1
        })
    })
   window.onload=loadData();
    function loadData() { 
        $.ajax({
            type:"POST",
            url:"<%:Url.Action("Load","User_Productwater") %>",
            data:"pageSize="+pageSize+"&expiresDate="+expiresDate+"&expiresDate2="+expiresDate2+"&opeator="+opeator+"&select="+select+"",
            cache:false,
            success:function(txt)
            {
                $(".DGHeaderStyle").nextAll().remove();
                $("#showWater").append(txt);
                newPage("首页");
            }
           });

              $.ajax({
            type:"POST",
            url:"<%:Url.Action("Data_Load_maxPage","User_Productwater") %>",
            data:"pageSize="+pageSize+"&expiresDate="+expiresDate+"&expiresDate2="+expiresDate2+"&opeator="+opeator+"&select="+select+"",
            cache:false,
            success:function(html)
            {
                $("#maxPage").html(html);
               
            }
        });
    }

       function newPage(sa)
        {
           var CurrentPage= $("#CurrentPage").html();
             var maxPage=$("#maxPage").html();
           
            maxPage=parseInt(maxPage);
            
            
            if(sa=="首页")
            {
                pageNum=1;
               document.getElementById("CurrentPage").innerHTML=pageNum;
            }
            if(sa=="下一页")
            {
                 if(CurrentPage>=maxPage)
                {
                     alert("已是最大页数");
                    return;
                }
                pageNum++;
                document.getElementById("CurrentPage").innerHTML=pageNum;
               
            }
            if(sa=="上一页")
            {
                 if(CurrentPage==1)
            {
              alert("已是最小页数");
                return;
            } 
                pageNum--;
                document.getElementById("CurrentPage").innerHTML=pageNum;
            }
            if(sa=="末页")
            {
                pageNum=maxPage;
                 document.getElementById("CurrentPage").innerHTML=pageNum;
            }
              $.ajax({
                type:"POST",
                url:"<%:Url.Action("newPage","User_Productwater") %>",
                data:"pageNum="+pageNum+"&pageSize="+pageSize+"&expiresDate="+expiresDate+"&expiresDate2="+expiresDate2+"&opeator="+opeator+"&select="+select+"",
                cache:false,
                success:function(txt)
                {
                   $(".DGHeaderStyle").nextAll().remove();
                   $("#showWater").append(txt);
                }
            })
        }
   //按条件查询
    function SelectByTime(){
        expiresDate = $("#expiresDate").val();
        expiresDate2 = $("#expiresDate2").val();
        opeator=$("#operator option:selected").text();
        select=true;
        loadData();
    }
    //清空日志
    function delWater(){
     var op=$("#operator option:selected").text();

         $.layer({
                  shade:[0.5,'#000',true],
                  area:['310px', '130px'],
                  dialog:{
                      msg:'您确定要删除'+op+'的全部记录吗',
                      btns:2,
                      type:4,
                      btn: ['确定','取消'],
                      yes:function(){
                          $.ajax({
                             type:"POST",
                              url:"<%:Url.Action("delWater","User_Productwater") %>",
                             data:"op="+op+"",
                             cache:false,
                             success:function(txt){
                              layer.msg(txt,2,function(){location.reload('<%:Url.Action("User_Productwater","User_Productwater") %>');});
                                 }
                            })

                      },no:function(){
                         layer.closeAll();
                      }
                  }
              
              });
    
    }
     //导出
      function daochu(){
      window.open('<%:Url.Action("UserWaterToExcel","User_Productwater") %>');
      }
       //关闭窗口
    function closeWindows() {
        window.location.href = "/Loading/Index/?src=/Desktop/Index/";
    }
 </script>
